package com.kabigon.tiny.test;

import com.kabigon.tiny.test.bean.entity.Example;
import com.sun.codemodel.JCodeModel;
import org.jsonschema2pojo.*;
import org.jsonschema2pojo.rules.RuleFactory;

import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;

public class CreateBean2Json {
    public static void main(String[] args) throws IOException {

        JCodeModel codeModel = new JCodeModel();

        URL source = Example.class.getResource("/test/xx.json");

        GenerationConfig config = new DefaultGenerationConfig() {
            @Override
            public boolean isGenerateBuilders() { // set config option by overriding method
                return true;
            }
        };

        SchemaMapper mapper = new SchemaMapper(new RuleFactory(config, new Jackson2Annotator(config), new SchemaStore()), new SchemaGenerator());
        mapper.generate(codeModel, "ClassName", "com.example", source);

        codeModel.build(Files.createTempDirectory("required").toFile());

    }
}
